package controller;


import common.result.TaotaoResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import service.SearchService;


@Controller
public class SearchController {

	@Autowired
	private SearchService service;
	
	@RequestMapping("/search")
	public @ResponseBody
	TaotaoResult search(@RequestParam(defaultValue="") String keywords, @RequestParam(defaultValue="1") Integer page, @RequestParam(defaultValue="10") Integer rows) throws Exception {
		keywords= new String(keywords.getBytes("iso8859-1"), "utf-8") ;
		return service.search(keywords, page, rows);
	}
	@RequestMapping("/importAll")
	@ResponseBody
	public TaotaoResult importData() throws Exception {
		return service.importData();
	}

	
}
